package com.song.JavaThread_ch3_4;

import java.util.concurrent.CountDownLatch;

public class Videoconference implements Runnable
{
	
	private final CountDownLatch controller;
	
	
	
	public Videoconference(int num) {
		super();
		this.controller = new CountDownLatch(num);
	}

	
	public void arrive(String name)
	{
		System.out.printf(" %s has arrived. \n" ,name);
		controller.countDown();
		System.out.printf(" VideoConference :Waiting for %d participants .\n",controller.getCount());
		
	}

	public void run() {
		System.out.printf(" VideoConference  init count is %d" ,controller.getCount());
		
		try {
			controller.await();
			System.out.printf(" VideoConference :all participants is come let's start ");

		} catch (InterruptedException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	
}
